import re
from selenium import webdriver
import time
from NBVisiter import NBVisitor

"""
{
  "username": "",
  "date": "",
  "text": "六月影人\n山东理工，耻为大学\n6-22 08:08",
  "fabulous": "0",
  "reply_num": 0,
  "reply": []
}
"兰州保先炳\n假冒的公务员少吗？@国家税务总局\n烙秋1:假冒的但没顶替，性质完全不同\n工人家的小孩儿:不应该只问税务总局吧\n共4条回复\n6-21 18:28\n1
"烙秋1\n是中国山东出奇葩吗\n6-24 23:26"

"""


class M_WEIBO_CN_Visiter(NBVisitor):
    def reply_processor(self, reply_text: str):
        reply_split = reply_text.split('\n')
        if len(reply_split) >= 3:
            pass
        else:
            return {}
        username = reply_split[0]
        text = reply_split[1]
        mydate = ""
        if len(reply_split) == 3:
            mydate = reply_split[-1]
        elif len(reply_split) >= 4:
            mydate = reply_split[-2]

        return self.build_a_weibo(
            username=username,
            date=self.full_time(mydate),
            text=text,
        )

    def fabulous_processor(self, text):
        return str(text)


# "text": "耗社会主义股市羊毛 :这个事情陈秀娟应该告山东省教育厅，会获得赔偿的\n7-3 16:12\n31\n哈罗MrBing:嗯，陈春秀都已经在网上爆出来了，完全可以搏一搏要些补偿费\n7-4 07:45",
class WEIBO_COM_Visiter(NBVisitor):
    def reply_processor(self, reply_text):
        a = str(reply_text).split('\n')
        if len(a) >= 3:
            pass
        else:
            return {}
        return self.build_a_weibo(
            username=a[0].split(":")[0],
            text=a[0].split(":")[1],
            date=self.full_time(a[1]),
            fabulous=self.fabulous_processor(a[2])
        )

    def fabulous_processor(self, text):
        return str(text)


class WEIBO_COM_2(NBVisitor):
    def reply_processor(self, reply_text: str):
        reply_split = reply_text.split('\n')
        if len(reply_split) >= 3:
            pass
        else:
            return {}
        username = reply_split[0].split('：')[0]
        text = reply_split[0].split('：')[1]
        mydate = ""
        if reply_split[-1].find("条回复") >= 0:
            mydate = reply_split[-2]
        else:
            mydate = reply_split[-1]

        return self.build_a_weibo(
            username=username,
            date=self.full_time(mydate),
            text=text,
        )

    def fabulous_processor(self, text):
        return str(text)
